{extend name="public:base" /}
{block name="content"}
<link rel="stylesheet" href="__CSS__/addcomon.css">
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css">

<style>
    input.error { border: 1px solid red; }
    label.error {
        font-weight: bold;
        color: #EA5200;
    }
</style>

<div class="row" style="padding:15px;">
    <div class="col-xs-12" id="vueApp">
        <form id="commentForm" action="{:url('edit')}" method="post">
            <div class="box">
            <div class="box-header" data-original-title="" style="height: 40px;">
                <h2><i class="glyphicon glyphicon-plus"></i>编辑任务</h2>
            </div>
            <div class="add-box">
                <div class="box-left">
                    <div class="form-group">
                        <label>任务类型:</label>
                        <!--<select class="form-control" name="rwlx_id" id="rwlx_id" disabled>-->
                            <!--<option value="">请选择类型</option>-->
                            <!--{volist name="renwuleixing" id="vo"}-->
                            <!--<option value="{$vo.id}" {eq name="info.id" value="$vo.id"}selected{/eq} >{$vo.name}</option>-->
                            <!--{/volist}-->
                        <!--</select>-->
                        <input type="text" name="rwlx_id"  class="form-control"  value="{$info.rwlx_text}" disabled>
                    </div>
                    <div class="form-group" style="display: none;" id="depar_id" >
                        <label>部门:</label>
                        <select class="form-control" name="depar_id"  disabled >
                            <option value="">请选择部门</option>
                            {volist name="depar" id="vo"}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="form-group" style="display: none;" id="ygroup_id" >
                        <label>邀约分组:</label>
                        <select class="form-control" name="ygroup_id"  disabled>
                            <option value="">请选择分组</option>
                            {volist name="ygroup" id="vo"}
                            <option value="{$vo.id}" {eq name="info.ygroup_id" value="$vo.id"}selected{/eq}  >{$vo.group_name}</option>
                            {/volist}
                        </select>
                    </div>
                    <!--<div class="form-group" style="display: none;">-->
                        <!--<label>拍摄场馆:</label>-->
                        <!--<input type="text" name="pid"  required class="form-control">-->
                    <!--</div>-->
                    <div class="form-group">
                        <label>月份:</label>
                        <input type="text" name="date"  required class="form-control" id='datetimepicker4' value="{$info.date}" disabled>
                    </div>
                    <div class="form-group" >
                        <label>目标任务:</label>
                        <input type="text" name="renwu"  required class="form-control" value="{$info.renwu}">
                    </div>

                    <input type="hidden" name="id"  value="{$info.id}">
                    <div class="form-group">
                        <label>是否启用:</label>
                        <input name="status" value="1" type="checkbox" checked />
                    </div>
                </div>
                <div class="btn-box">
                    <button type="submit" class="btn btn-color-o" id="submit">确定</button>
                    <button type="reset" class="btn btn-color-g">重置</button>
                </div>
            </div>
        </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
<script type="text/javascript" src="__STATIC__/validate/jquery.validate.min.js"></script>
<script src="//cdn.bootcss.com/moment.js/2.18.1/locale/zh-cn.js"></script>
<script type="text/javascript" src="//cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>

<script type="text/javascript">
    $(function () {
        $('#datetimepicker4').datetimepicker({
            format: 'YYYY-MM',
//            defaultDate : new Date()
        });
    });
</script>

<script>
    $().ready(function() {

        if( $('#rwlx_id').val() == 2 ){
            $('#ygroup_id').show();
        }
        if( $('#rwlx_id').val() == 3 ){
            $('#depar_id').show();
        }

        // 在键盘按下并释放及提交后验证提交表单
        $("#commentForm").validate({
            rules: {
//                rwlx_id:{ required : true},
//                date:   { required : true,date:true},
                renwu:  { required : true,digits:true},
            },
            messages: {
//                rwlx_id: 	"选择任务类型",
//                date:       { required:"请输入日期",date:"日期格式错误"},
                renwu:	    { required:"请输入任务",digits:"输入正整数"},
            },
            submitHandler: function(form)
            {
                $.ajax({
                    type: "POST",
                    url:  "{:url('edit')}",
                    data: $(form).serialize(),
                    beforeSend:function(){
                        $('#submit').attr("disabled","false"); //禁止点击
                    },
                    success: function(msg){
//                        console.log(msg);
                        if(msg.status==1){
                            $('#submit').attr("disabled","false"); //禁止点击
                            layer.msg(msg.info, {icon: 1});
                            setTimeout(function(){
                                location.href=msg.url;
                            },3000); //延迟演示
                        }else{
                            layer.msg(msg.info, {icon: 2});
                            $('#submit').removeAttr("disabled"); //禁止点击
                        }

                    }
                });
            }

        });
        return false;
    });
    highlight_subnav("{:url('index')}");
</script>
{/block}